home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / 80x0393.zip / UART_TUT.FAQ < prev    next >
Text File  |  1993-03-30  |  27KB  |  593 lines

  1.                       The Serial Hardware Tutorial
  2.                 By Yousuf J. Khan (FidoNet 1:163/215.4)
  3.                          Revision: Jan 20, 1993
  4.  
  5. Serial communications on the IBM PC and compatible range of computers
  6. conforms to the RS-232C serial port standard. The chip that implements
  7. and controls the RS-232 serial port is the UART.
  8.  
  9. BIOS Data Segment
  10. -----------------
  11. The base port addresses of each UART can be pointed to by reading the
  12. four memory words at offset 0, 2, 4, and 6 from the start of the BIOS
  13. Data Segment (BDS), segment 40h. Each word points to the starting port
  14. address of a UART assembly. These pointer words are known commonly as
  15. COM1, COM2, COM3, and COM4.
  16.  
  17. Some standard base port locations to put the UART assemblies are at
  18. ports 02E8h, 02F8h, 03E8h, and 03F8h, in no particular order. If one of
  19. the port pointers is zero, then that indicates that a serial port does
  20. not exist there.
  21.  
  22. Any code snippets in this tutorial are compatible with Tasm 2.0
  23. assembler (but likely will work with many other versions of assemblers).
  24. They may refer to a fictional memory location known as [COMX]. [COMX] is
  25. a word variable representing anything from COM1 through COM4.
  26.  
  27. The UART
  28. --------
  29. There have been about four major functional revisions of the UART. The
  30. first one in the series was the National Semiconductor 8250.
  31.  
  32. The next version was the NS 16450. There was also an 8250A, which was
  33. functionally identical to the 16450, therefore is really just a 16450.
  34. The addition of a scratch register is what distinguishes a 16450 from
  35. the 8250.
  36.  
  37. After the 16450, came the 16550A. The 16550A added a 16 byte FIFO buffer
  38. to the data register. The FIFOs insulate the serial communications from
  39. disruptions caused by high interrupt latencies in the computer. There
  40. was also a 16550 (non-A), but that one had disfunctional FIFOs, so it
  41. looks and acts just like a 16450. From now on any references to a
  42. "16550" assumes we are talking about the 16550A revision and later.
  43.  
  44. The most recent addition to the family are the Type 3 UARTs, found in
  45. late model IBM PS/2's. The Type 3's can read and write data using the
  46. DMA circuitry of the PC. There is also a new, switchable, higher speed
  47. baud rate clock on the Type 3's, which raise maximum baud rates by 6
  48. fold.
  49.  
  50. The Data register (offset 0)
  51. ----------------------------
  52. The data register is at offset zero in the port addresses. If you read
  53. from it, it becomes the Receive Data register, and if you write to it,
  54. it becomes the Transmit Data register. The data register is eight bits
  55. long, and is common to all revisions.
  56.  
  57. If you have an UART with FIFOs (ie. 16550+ only), and they are enabled,
  58. then you do not have to stop reading or writing after doing just one.
  59. You may simply keep reading until the receiver FIFO is empty. Or you may
  60. simply keep writing until the transmitter FIFO is full. Each character
  61. will get pushed up through the FIFO stack.
  62.  
  63. The Interrupt Enable register (offset 1)
  64. ----------------------------------------
  65. At the port offset one is the Interrupt Enable register. This register
  66. controls what sorts of change of state will cause the UART to interrupt
  67. the CPU. You write to this port to set the states, and you read from
  68. this port to get the states. Only the first four bits (bits 0-3) are
  69. defined, the remainder are zero.
  70.  
  71.          7    4   3    2   1   0
  72.         ┌──────┬────┬────┬───┬───┐
  73.         │ 0000 │ MS │ LS │ T │ R │
  74.         └──────┴────┴────┴───┴───┘
  75.  
  76.         Bit 0 (R): enable Receive data ready int
  77.         Bit 1 (T): enable Transmit data empty int
  78.         Bit 2 (LS): Line Status int. Any change in the Line Status
  79.                 register with this bit set will cause an int.
  80.         Bit 3 (MS): Modem Status int. Any change in the Modem Status
  81.                 register with this bit set will cause an int.
  82.         Bits 4-7: reserved, cleared.
  83.  
  84. Sample code:
  85.         ;The following is an example of setting only the MS bit without
  86.         ;turning on any of the other bits.
  87.         ...
  88.         IER     record  ms:1,ls:1,t:1,r:1
  89.         mov     dx, [comx]              ;get comport address
  90.         inc     dx                      ;one offset from base
  91.         mov     al, IER <1,0,0,0>       ;set just MS bit
  92.         out     dx, al
  93.         ...
  94.  
  95. The Interrupt ID register (offset 2)
  96. ------------------------------------
  97. The register at this offset has a split personality depending on whether
  98. you are reading from or writing to it. If you are reading from it, then
  99. this is the Interrupt ID reg. For the 8250 & 16450, this register has
  100. only the bit fields 0-2 defined. For the 16550 and above, three
  101. additional bit fields have been defined. All undefined fields, on any
  102. particular revision, are cleared.
  103.  
  104.          7    6 5  4   3  2  1  0
  105.         ┌──────┬────┬────┬────┬───┐
  106.         │ FIFO │ 00 │ FT │ ID │ I │
  107.         └──────┴────┴────┴────┴───┘
  108.  
  109.         Bit 0 (I): Interrupt pending. Simply indicates an interrupt
  110.                 occurred, but not what the cause was (as set by
  111.                 Interrupt Enable register).
  112.         Bits 1-2 (ID): Indicates what the cause of the interrupt was.
  113.                 00b     Look in Modem Status register
  114.                 01b     Transmit data int occurred
  115.                 10b     Receive data int occurred
  116.         Bit 3 (FT): 16550+ only. FIFO Timeout. Set only in conjunction
  117.                 with ID bits = 10b (Receive data) condition. Allows the
  118.                 processor to read the last few bytes left in the FIFO
  119.                 buffer, which would otherwise be not enough to trigger a
  120.                 full receive data int.
  121.         Bits 4-5: reserved, cleared
  122.         Bits 6-7 (FIFO): 16550+ only. Mode status.
  123.                 00b     Char mode, ie. emulate 8250 or 16450.
  124.                 01b     DMA mode. Type 3 UART only.
  125.                 11b     FIFO mode.
  126.  
  127. Sample code:
  128.         ;The following is a sample interrupt handler which determines
  129.         ;if an int occurred & what sort of int occurred.
  130.         ...
  131.         IID     record  fifo:2,rsrv:2=0,ft:1,id:2,i:1
  132.         mov     dx, [comx]
  133.         add     dx, 2           ;two offsets from base
  134.         in      al, dx
  135.         test    al, mask i      ;did an int occur on this comport?
  136.         jne     no_irq          ;no? then branch
  137.         and     al, mask id     ;mask all but ID bits
  138.         cmp     al, iid <,,,01b,>;transmit data empty int?
  139.         pop     ax              ;restore AL
  140.         je      transdata       ;yes? then write to buffer
  141.         cmp     al, iid <,,,10b,>;received data int?
  142.         je      rcvdata         ;yes? then read buffer
  143.         ...
  144. rcvdata:
  145.         ...
  146. transdat:
  147.         ...
  148. no_irq:
  149.         ...
  150.  
  151. The FIFO Control register (offset 2)
  152. ------------------------------------
  153. This is the other half of the Interrupt ID register, but only available
  154. in write mode, and only available on the 16550+ UART. It is used to
  155. control various aspects of the FIFO buffers.
  156.  
  157.          7   6 5   3   2    1    0
  158.         ┌─────┬─────┬────┬────┬────┐
  159.         │ FTS │ 000 │ TR │ RR │ FE │
  160.         └─────┴─────┴────┴────┴────┘
  161.  
  162.         Bit 0 (FE): FIFO Enable
  163.         Bit 1 (RR): Receive buffer reset
  164.         Bit 2 (TR): Transmit buffer reset
  165.         Bits 3-5: reserved, cleared
  166.         Bit 6-7 (FTS): FIFO Trigger Size. Sets how full the receive
  167.                 FIFOs may get before it ints.
  168.                 00b     1 byte
  169.                 01b     4 bytes
  170.                 10b     8 bytes
  171.                 11b     14 bytes
  172.  
  173. The Line Control register (offset 3)
  174. ------------------------------------
  175. Common to all revisions. You use this register to set things like baud
  176. rates, word size, parity, etc.
  177.  
  178.           7   6    5    4   3   2  1  0
  179.         ┌───┬───┬────┬────┬───┬───┬────┐
  180.         │ D │ B │ SP │ EP │ P │ S │ WS │
  181.         └───┴───┴────┴────┴───┴───┴────┘
  182.  
  183.         Bits 0-1 (WS): Word Size. Number of data bits.
  184.                 00b     5 bits
  185.                 01b     6 bits
  186.                 10b     7 bits
  187.                 11b     8 bits
  188.         Bit 2 (S): Number of Stop bits (one or two)
  189.         Bit 3 (P): Parity enable. Parity checking is done as a
  190.                 primitive form of error checking. It involves counting
  191.                 up the number of 1 data bits in the data word. If EP is
  192.                 set, then parity is set such that it will make the
  193.                 number of 1's even. Otherwise it is set such that it
  194.                 will make the number of 1's odd.
  195.         Bit 4 (EP): Even Parity (set=even, cleared=odd)
  196.         Bit 5 (SP): Sticky Parity. This is not really parity checking.
  197.                 If the P and SP bits are set, then this simply sets the
  198.                 parity bit either on or off all the time. It's not so
  199.                 much an error check as it is a place marker, so the
  200.                 receiver will always see a known bit at the exact same
  201.                 point in the data flow.
  202.         Bit 6 (B): Send Break. Some comm programs require that this
  203.                 special modem signal be sent to end transmissions for
  204.                 example. While this bit is set the break signal will be
  205.                 continuously sent over the modem, until this bit is
  206.                 cleared.
  207.         Bit 7 (D): Access Divisor Latch. This is used to set the baud
  208.                 rates. When this bit is set, it takes over the Data and
  209.                 Interrupt Enable registers (offsets 0 and 1), and turns
  210.                 them into Baud Rate Divisor (BRD) register. All the
  211.                 revisions have a 1.8432 MHz countdown clock. The Type 3
  212.                 can also switch to an optional 11.0592 MHz clock. The
  213.                 BRD register is a 16 bit counter. It counts down every
  214.                 clock tick, until it reaches zero, at which point it
  215.                 transmits or receives another bit on the line. At 1.8432
  216.                 MHz, some common BRD values are: 96d = 1200 baud, 12d =
  217.                 9600 baud, 1d = 115,200 baud.
  218.  
  219. Sample code:
  220.         ;The following is sample code to set baud rates
  221.         ...
  222.         LCR     record  d:1,b:1,sp:1,ep:1,p:1,s:1,ws:2
  223.         mov     dx, [comx]
  224.         add     dx, 3
  225.         in      al, dx          ;get current settings
  226.         push    ax              ;save AL
  227.         or      al, mask d      ;turn on D bit in AL without affecting
  228.                                 ; any of other bits
  229.         out     dx, al          ;send command
  230.         mov     dx, [comx]      ;back to [COMX]
  231.         ;note: there's probably no reason to set the upper byte of the
  232.         ; BRD latch, because serial comm hardly ever gets that slow,
  233.         ; that it needs to be set. So just set lower byte of BRD.
  234.         mov     al, 12          ;ie. 9600 baud
  235.         out     dx, al          ;this reg is now BRD, not Data reg
  236.         add     dx, 3
  237.         pop     ax              ;restore AL
  238.         out     dx, al          ;set BRD back to Data
  239.         ...
  240.  
  241. The Modem Control register (offset 4)
  242. -------------------------------------
  243. This register is used mainly to communicate between the computer and the
  244. local modem. It is common to all revisions.
  245.  
  246.          7   5  4    3    2     1     0
  247.         ┌─────┬───┬────┬────┬─────┬─────┐
  248.         │ 000 │ L │ O2 │ O1 │ RTS │ DTR │
  249.         └─────┴───┴────┴────┴─────┴─────┘
  250.  
  251.         Bit 0 (DTR): Data Terminal Ready. Simply indicates to the modem
  252.                 that the data terminal (ie. the computer) is ready and
  253.                 waiting for the modem. The modem would then send a Data
  254.                 Set Ready (DSR) back to computer when it was ready.
  255.         Bit 1 (RTS): Request To Send. In the olden days before the
  256.                 current generation of smart modems, this was the signal
  257.                 to the modem to blindly place a carrier signal on the
  258.                 line. When connection to the remote modem was
  259.                 established, then the local modem would activate both
  260.                 the DCD and CTS signals back to the computer.
  261.         Bit 2 (O1): Out 1. Not used in PCs.
  262.         Bit 3 (O2): Out 2. Master Enable Interrupts. This bit enables or
  263.                 disables all interrupts, regardless of the state of the
  264.                 Interrupt Enable register.
  265.         Bit 4 (L): Loop. Reroutes the output of the transmitter back to
  266.                 the receiver. Used for testing the UART circuitry.
  267.         Bits 5-7: reserved, cleared
  268.  
  269. The Line Status register (offset 5)
  270. -----------------------------------
  271. This register indicates the status of the line. There are fields which
  272. indicate various errors that can occur in the line.
  273.  
  274.            7    6    5    4    3    2    1    0
  275.         ┌────┬────┬────┬────┬────┬────┬────┬────┐
  276.         │ RE │ TS │ TH │ BI │ FE │ PE │ OE │ DR │
  277.         └────┴────┴────┴────┴────┴────┴────┴────┘
  278.  
  279.         Bit 0 (DR): Data in Receive buffer
  280.         Bit 1 (OE): Overrun Error. Occurs if one doesn't read the
  281.                 receive buffer before the next character comes in.
  282.         Bit 2 (PE): Parity Error
  283.         Bit 3 (FE): Framing Error. It probably has something to do with
  284.                 start and stop bits being out of place.
  285.         Bit 4 (BI): Break Interrupt. Indicates a break signal coming
  286.                 from the other modem has been detected.
  287.         Bit 5 (TH): Transmitter holding register empty
  288.         Bit 6 (TS): Transmitter shift register empty
  289.         Bit 7 (RE): 16550+ only. Error in receive FIFO.
  290.  
  291. The Modem Status register (offset 6)
  292. ------------------------------------
  293. This register is common to all revisions. The register is split into two
  294. functional halves. The upper nibble indicates the current state of the
  295. DCD, RI, DSR, and CTS lines, while the lower nibble indicates whether
  296. any of these lines have changed since you last inspected them. I will
  297. prefix all the lower nibble, change fields with a "d", the calculus
  298. symbol for change.
  299.  
  300.             7    6     5     4      3     2      1      0
  301.         ┌─────┬────┬─────┬─────┬──────┬─────┬──────┬──────┐
  302.         │ DCD │ RI │ DSR │ CTS │ dDCD │ dRI │ dDSR │ dCTS │
  303.         └─────┴────┴─────┴─────┴──────┴─────┴──────┴──────┘
  304.  
  305.         Bit 0 (dCTS): Change in CTS
  306.         Bit 1 (dDSR): Change in DSR
  307.         Bit 2 (dRI): Change in RI
  308.         Bit 3 (dDCD): Change in DCD
  309.         Bit 4 (CTS): Clear To Send. Modem sets this line indicating that
  310.                 it is ready for data, after computer indicates that it
  311.                 is ready for data with an RTS. It used to be a signal
  312.                 that the local modem has connected with a remote modem
  313.                 too, in the olden days.
  314.         Bit 5 (DSR): Data Set Ready. This is the completing signal in a
  315.                 DTR-DSR pair. Computer sends DTR to modem, saying it
  316.                 wants to connect with it. Modem sends DSR back to
  317.                 computer, saying that connection has been established.
  318.         Bit 6 (RI): Ring Indicator. Indicates that there is remote modem
  319.                 attempting to call your local modem.
  320.         Bit 7 (DCD): Data Carrier Detect. Indicates that the remote
  321.                 modem has established connection with local modem.
  322.  
  323. The Scratch register (offset 7)
  324. -------------------------------
  325. Simply a place to jot down notes to yourself, does not affect UART
  326. operations at all. No functional purpose, except that it does
  327. distinguish the original 8250 from all later revisions. Only available
  328. on 16450+.
  329.  
  330. The Type 3 enhanced registers
  331. -----------------------------
  332. The next set of registers only apply to the IBM Type 3 DMA UART. This
  333. UART, on top of the fact that it can act just like a 16550 FIFO UART,
  334. can even read and write the data directly to memory without any
  335. intervention from the CPU. It also has a higher maximum baud rate than
  336. all previous revisions, thanks to a dual speed clock. The enhanced
  337. registers are all accessed at least 8000h offsets away from their base
  338. port. So if a baseport is found at 3F8h, then the first enhanced
  339. register will be found at 83F8h. So far this UART is only found on IBM
  340. PS/2 models 57, 90 & 95, but there is no reason why in the future they
  341. can't be installed on ISA machines either. All the input and output
  342. memory addresses are set by setting the PC's DMA channels (I don't know
  343. which channel, though). It is beyond the scope of this tutorial to show
  344. you how to control DMA channels.
  345.  
  346. Sample code:
  347.         ;Sample code to detect Type 3 UART
  348.         ...
  349.         ;this is a record for the bit fields of DMA CMD Reg 1
  350.         DCR1    record  dr:1,dt:1,rs:1,tcr:1,tct:1,se:1,te:1,rc:1
  351.         mov     dx, [comx]
  352.         add     dx, 8003h       ;8003h offsets from base
  353.         in      al, dx          ;get current settings
  354.         or      al, mask dt     ;turn on DMA transmit (DT) bit
  355.         mov     ah, al          ;save AL in AH
  356.         out     dx, al
  357.         mov     dx, [comx]
  358.         add     dx, 2           ;2 offsets from base, Int ID reg
  359.         in      al, dx          ;get current IID reg settings
  360.         ;restore the DMA CMD Reg 1 to original state
  361.         mov     dx, [comx]
  362.         add     dx, 8003h
  363.         xchg    al, ah          ;restore AL from AH, and save current AL
  364.         and     al, not mask dt ;turn off DT bit
  365.         out     dx, al
  366.         ;this is a record of the primary Int ID reg
  367.         IID     record  fifo:2,rsrv:2=0,ft:1,id:2,i:1
  368.         mov     al, ah          ;restore AL from AH
  369.         and     al, mask fifo   ;mask off FIFO mode bits
  370.         cmp     al, <1,,,,>     ;if FIFO mode bits = 1, 
  371.         je      yes_dma         ; then DMA mode is on
  372.         ...
  373. yes_dma:
  374.         ...
  375.  
  376. The Command register (offset 8000h)
  377. -----------------------------------
  378. This is a write-only register. Only the lower two bits are used, all the
  379. rest are reserved.
  380.  
  381.          7      2 1   0
  382.         ┌────────┬─────┐
  383.         │ 000000 │ CMD │
  384.         └────────┴─────┘
  385.  
  386.         Bits 0-1 (CMD): Command bits. Can be used to suspend a DMA
  387.                 transmit at any time.
  388.                 01b     Start sending
  389.                 10b     Stop sending
  390.                 11b     Reset error
  391.         Bits 2-7: reserved, cleared
  392.  
  393. The Secondary Interrupt ID register (offset 8001h)
  394. --------------------------------------------------
  395. In non-DMA mode, this register exactly matches the lower nibble of the
  396. primary Interrupt ID register (offset 2, read). However, there are two
  397. more bits defined in this register's upper nibble, because of the extra
  398. functionality.
  399.  
  400.          7  6 5  1  0
  401.         ┌────┬────┬───┐
  402.         │ 00 │ ID │ I │
  403.         └────┴────┴───┘
  404.  
  405.         Bit 0 (I): Interrupt pending
  406.         Bits 1-5 (ID): Interrupt ID.
  407.                 00000b  Modem status
  408.                 00001b  Transmit data
  409.                 00010b  Receive data
  410.                 00011b  Line status
  411.                 00110b  FIFO receive buffer timeout
  412.                 10000b  Receive DMA terminal count. If the TCR bit in
  413.                         the next register is set, then the UART will
  414.                         interrupt the processor, when it reaches the end
  415.                         of the DMA receive buffer.
  416.                 10001b  Transmit DMA terminal count. If TCT bit in next
  417.                         register is set. End of DMA transmit buffer.
  418.                 10010b  Receive Char Count. If RC bit in next reg is
  419.                         set. Ints everytime another byte is received, so
  420.                         you can check Char Count reg (offset 8007h).
  421.                 10011b  Transmit REGS empty. If TE bit in next reg is
  422.                         set. Ints if transmit register is empty.
  423.                 11000b  Compare match CHAR 0. If a match was made with
  424.                         first comparison character, and if first
  425.                         comparison function set to interrupt (see
  426.                         offsets 8005h and 8006h).
  427.                 11001b  Compare match CHAR 1
  428.                 11010b  Compare match CHAR 2
  429.         Bits 6-7: reserved, cleared
  430.  
  431. The DMA Control 1 register (offset 8003h)
  432. -----------------------------------------
  433. Enables and disables various interrupt conditions. Also enables DMA
  434. transmit and/or receive mode.
  435.  
  436.            7    6    5     4     3    2    1    0
  437.         ┌────┬────┬────┬─────┬─────┬────┬────┬────┐
  438.         │ DR │ DT │ RS │ TCR │ TCT │ SE │ TE │ RC │
  439.         └────┴────┴────┴─────┴─────┴────┴────┴────┘
  440.  
  441.         Bit 0 (RC): Enable receive Char Count int. If set, then it will
  442.                 int everytime there is a increment in the Char Count
  443.                 register (offset 8007h).
  444.         Bit 1 (TE): Enable Transmitter Empty int
  445.         Bit 2 (SE): Stop transmission on receive error
  446.         Bit 3 (TCT): Enable Transmit Terminal Count int
  447.         Bit 4 (TCR): Enable Receive Terminal Count int
  448.         Bit 5 (RS): Store Status with Received data. If this is enabled,
  449.                 then UART will store a byte of Line Status info right
  450.                 after the data byte. Allows the CPU to see how valid
  451.                 each data byte that came in was, without being
  452.                 interrupted for each error.
  453.         Bit 6 (DT): Enable DMA transmit
  454.         Bit 7 (DR): Enable DMA receive
  455.  
  456. The DMA Control 2 register (offset 8004h)
  457. -----------------------------------------
  458. The lower nibble of this register enables various hardware flow control
  459. options. The upper nibble controls software flow pacing.
  460.  
  461. The Type 3 UART has two flow clock speeds, switchable via the HF bit.
  462. The lower speed clock is 1.8432 MHz like all previous revisions, and is
  463. there to maintain compatibility with those previous revisions. The
  464. higher speed clock is 11.0592 MHz. This results in maximum throughput
  465. going from 115,200 baud to 691,200 baud.
  466.  
  467.            7    6    5    4      3      2      1      0
  468.         ┌────┬────┬────┬────┬──────┬──────┬──────┬──────┐
  469.         │ BP │ HF │ ST │ SR │ RDSR │ TDCD │ TDSR │ TCTS │
  470.         └────┴────┴────┴────┴──────┴──────┴──────┴──────┘
  471.  
  472.         Bit 0 (TCTS): Control transmitter via CTS status
  473.         Bit 1 (TDSR): Control transmitter via DSR status
  474.         Bit 2 (TDCD): Control transmitter via DCD status
  475.         Bit 3 (RDSR): Control receiver via DSR status
  476.         Bit 4 (SR): Slow receiver by a fixed factor of 16. Allows slower
  477.                 CPUs to keep up.
  478.         Bit 5 (ST): Slow transmitter by a fixed factor of 16
  479.         Bit 6 (HF): Use High-speed Flow clock
  480.         Bit 7 (BP): Byte pacing. When set, uses the Byte Pacer register
  481.                 (offset 8007h, write), to slow baud rate by 256*value of
  482.                 Byte Pacer.
  483.  
  484. The DMA Control 3 register (offset 8005h)
  485. -----------------------------------------
  486. Only the lower three bits of this register are defined. They are used to
  487. set the action to be taken when the UART encounters one of three
  488. possible compare characters, and what those three compare characters
  489. are. These three characters may be software control characters.
  490.  
  491. In the next port offset, are either the Character Compare registers or
  492. the Compare Function registers. The AC bit chooses either the Compare or
  493. the Function register. The CCA bits choose which one of three Compare or
  494. Function registers.
  495.  
  496.          7     3 2   1   0
  497.         ┌───────┬─────┬────┐
  498.         │ 00000 │ CCA │ AC │
  499.         └───────┴─────┴────┘
  500.  
  501.         Bit 0 (AC): Register type select
  502.                 0       func reg
  503.                 1       char reg
  504.         Bit 1 (CCA): Register number select
  505.                 00b     reg 1
  506.                 01b     reg 2
  507.                 10b     reg 3
  508.         Bits 3-7: reserved, cleared
  509.  
  510. The Character Compare registers (offset 8006h)
  511. ----------------------------------------------
  512. There are three of these registers, each of which are bank switched from
  513. the same port offset. Whenever the UART encounters any one of the three
  514. characters stored at each register, it executes the required action from
  515. the corresponding Compare Function registers (see next port).
  516.  
  517.          7         0
  518.         ┌───────────┐
  519.         │           ├┐  Char 0
  520.         └┬──────────┘├┐  Char 1
  521.          └┬──────────┘│   Char 2
  522.           └───────────┘
  523.  
  524. Each Character Compare (CC) register may contain any 8-bit value. The CC
  525. registers are gettable/settable whenever AC in the DMA Control 3
  526. register is set. Each specific CC register is chosen from the CCA bits
  527. in DMA Control 3.
  528.  
  529. The Compare Function registers (offset 8006h)
  530. ---------------------------------------------
  531. Each of these CF registers complement each of the CC registers. They
  532. specify what action is to be taken whenever a data character comes in
  533. matching one of the CC characters. Only the lower nibble of these
  534. registers is defined.
  535.  
  536.          7    4       3       2     1     0
  537.         ┌──────┬────────┬───────┬─────┬─────┐
  538.         │ 0000 │ STARTT │ STOPT │ DEL │ INT ├┐  Func 0
  539.         └┬─────┴┬───────┴┬──────┴┬────┴┬────┘├┐  Func 1
  540.          └┬─────┴┬───────┴┬──────┴┬────┴┬────┘│   Func 2
  541.           └──────┴────────┴───────┴─────┴─────┘
  542.  
  543.         Bit 0 (INT): Int CPU if match found
  544.         Bit 1 (DEL): Delete character if match found
  545.         Bit 2 (STOPT): Stop transmitter if match found
  546.         Bit 3 (STARTT): Start transmitter if match found
  547.         Bit 4-7: reserved, cleared
  548.  
  549. Any of those above bits may be set independently, but of course if bits
  550. 2 & 3 are both set, they'll likely cancel out.
  551.  
  552. The Char Count register (offset 8007h)
  553. --------------------------------------
  554. Read mode only. This register shares this port offset with the Byte
  555. Pacer Register, which operates in write mode only. This contains an
  556. 8-bit count of the number of characters received. If RC in DMA Control 1
  557. is set, then everytime this register changes, then the CPU is alerted by
  558. an interrupt.
  559.  
  560. The Byte Pacer register (offset 8007h)
  561. --------------------------------------
  562. Write mode only. If the BP bit in DMA Control 2 is set then the value of
  563. this register times 256 is used as the factor to slow down the baud rate
  564. with.
  565.  
  566. Acknowledgments
  567. ---------------
  568. -Douglas Boling, of PC Magazine. His serial port articles in PC Mag, May
  569. 12th and 26th, 1992 got me started on this tutorial of my own.
  570.  
  571. -Matthew Hildebrand, of Fidonet 1:247/128.2, for some of his insights.
  572.  
  573. Revision History
  574. ----------------
  575. Description of changes made to The Serial Hardware Tutorial:
  576.  
  577. Jan 1, 1993     -First release
  578.  
  579. Jan 15, 1993    -Second release
  580.                 -Contained a small clarification about the purpose of
  581.                 Break in the Line Control and Line Status registers.
  582.                 -Contains a clarification to a minor bit of confusion
  583.                 about how to choose DMA memory locations for the Type 3
  584.                 DMA UARTs.
  585.                 -Looking for information on which DMA channel the Type
  586.                 3's use. If anybody has this information, let me know.
  587.  
  588. Jan 20, 1993    -Third release
  589.                 -Contains a more definitive definition of the Break bit
  590.                 in the Line Control and Line Status registers.
  591.                 -Still searching for info on which DMA channel is used
  592.                 by Type 3's.
  593.